package com.zh.domain.entity;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.zh.domain.Model.BaseEntity;
import com.zh.domain.vo.user.UserVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.io.Serializable;
import java.util.List;

/**
 * @TableName users
 */
@TableName(value = "users", autoResultMap = true)
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(value = "User",description = "用户表")
public class User extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;
    @TableId(type = IdType.AUTO)
    @ApiModelProperty("用户id")
    private Integer id;
    @ApiModelProperty("用户名不超过32位")
    private String username;
    @ApiModelProperty("密码(加密后，原密码不超过32位)")
    private String password;
    @ApiModelProperty("salt")
    private String salt;
    @ApiModelProperty("昵称")
    private String nickname;
    @ApiModelProperty("用户简介不超过255位")
    private String profile;
    @ApiModelProperty("姓名不超过32位")
    private String name;
    @ApiModelProperty("邮箱")
    private String email;
    @ApiModelProperty("手机号")
    private String phone;
    @ApiModelProperty("头像")
    private String avatar;
    @ApiModelProperty("技术栈标签")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> tags;
    @ApiModelProperty("角色super-admin/admin/user")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> roles;
    @ApiModelProperty("账号类型 custom/special")
    private String type;
    @ApiModelProperty("转换成VO视图")
    public UserVO toUserVo() {
        UserVO userVO = new UserVO();
        BeanUtil.copyProperties(this,userVO);
        return userVO;
    }
}